﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(ColliderDrawer))]
public class ColliderDrawerEditor : Editor {

    void OnSceneGUI() {

        Handles.BeginGUI();
        var c = GUI.color;
        GUI.color = Color.green;
        GUILayout.Label("选择Buidings后，鼠标右键可以选场景中的Collider2D物体", GUILayout.MinHeight(60f));
        GUI.color = c;
        Handles.EndGUI();

        Event ev = Event.current;

        switch (ev.type) {
        case EventType.MouseUp: {
                Ray ray = HandleUtility.GUIPointToWorldRay(ev.mousePosition);
                var hit = Physics2D.OverlapPoint(ray.origin);
                if (hit != null) {
                    Selection.activeGameObject = hit.gameObject;
                }
            }
            break;
        }

    }

}
